﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using FortuneHeavenBAL;
using FortuneHeaven.Admin.Common;

namespace FortuneHeaven.Admin.Pages.GameManager
{
    public partial class GiveScoreList : FortuneHeaven.Admin.Common.PageBase
    {
        public override string PageID
        {
            get { return "F55"; }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            lblDeptName.Text = "赠送积分";
            this.usPager.PagerChanged += new Admin.Controls.Pagination.PagerChangeHandler(usPager_PagerChanged);
            if (!this.IsPostBack)
            {
                this.drpPagerSize.Items.Clear();
                this.drpPagerSize.Items.Add(new ListItem("每页10行", "10"));
                this.drpPagerSize.Items.Add(new ListItem("每页20行", "20"));
                this.drpPagerSize.Items.Add(new ListItem("每页50行", "50"));

            

                if (!string.IsNullOrEmpty(Request["pagesize"]))
                {
                    this.drpPagerSize.SelectedIndex = int.Parse(Request["pagesize"]);
                }
                else
                {
                    this.drpPagerSize.SelectedValue = "10";
                }

                if (!string.IsNullOrEmpty(Request["current"]))
                {
                    ResetList(int.Parse(Request["current"]));
                }
                else
                {
                    ResetList();
                }
                //this.lvNews.ItemCommand += new EventHandler<ListViewCommandEventArgs>(lvNews_ItemCommand);

            }
        }
        private void usPager_PagerChanged(object sender, int currentpage)
        {
            Refresh();
        }

        public void Refresh()
        {
            cftt_zsjfBO giftorder = new cftt_zsjfBO();
            lvNews.DataSource = giftorder.GetList(this.usPager.CurrentPageIndex, int.Parse(this.drpPagerSize.SelectedValue), this.txtFromUser.Text,this.txtToUser.Text);
            lvNews.DataBind();
        }

        protected void drpPagerSize_SelectedIndexChanged(object sender, EventArgs e)
        {
            ResetList();
        }

        public void ResetList()
        {
            ResetList(1);
        }

        public void SearchValue(object sender, EventArgs e)
        {
            ResetList();
        }

        public void ResetList(int current)
        {
            cftt_zsjfBO giftorder = new cftt_zsjfBO();
            this.usPager.RecordCount = giftorder.GetTotalSize(this.txtFromUser.Text, this.txtToUser.Text);
            this.usPager.PageSize = int.Parse(this.drpPagerSize.SelectedValue);
            this.usPager.Initial();
            this.usPager.CurrentPageIndex = 1;
        }
      
    }
}